package net.mcreator.compresstools.procedures;

import net.minecraft.world.World;
import net.minecraft.world.IWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.block.Block;

import net.mcreator.compresstools.CompressToolsMod;

import java.util.Map;

public class CompressDiamondAxeRightProcedure {

	public static void executeProcedure(Map<String, Object> dependencies) {
		if (dependencies.get("world") == null) {
			if (!dependencies.containsKey("world"))
				CompressToolsMod.LOGGER.warn("Failed to load dependency world for procedure CompressDiamondAxeRight!");
			return;
		}
		if (dependencies.get("x") == null) {
			if (!dependencies.containsKey("x"))
				CompressToolsMod.LOGGER.warn("Failed to load dependency x for procedure CompressDiamondAxeRight!");
			return;
		}
		if (dependencies.get("y") == null) {
			if (!dependencies.containsKey("y"))
				CompressToolsMod.LOGGER.warn("Failed to load dependency y for procedure CompressDiamondAxeRight!");
			return;
		}
		if (dependencies.get("z") == null) {
			if (!dependencies.containsKey("z"))
				CompressToolsMod.LOGGER.warn("Failed to load dependency z for procedure CompressDiamondAxeRight!");
			return;
		}
		IWorld world = (IWorld) dependencies.get("world");
		double x = dependencies.get("x") instanceof Integer ? (int) dependencies.get("x") : (double) dependencies.get("x");
		double y = dependencies.get("y") instanceof Integer ? (int) dependencies.get("y") : (double) dependencies.get("y");
		double z = dependencies.get("z") instanceof Integer ? (int) dependencies.get("z") : (double) dependencies.get("z");
		double fx = 0;
		double fy = 0;
		double fz = 0;
		double nx = 0;
		double judge = 0;
		double nz = 0;
		fx = (x - 8);
		fy = 63;
		fz = (z - 8);
		nx = fx;
		nz = fz;
		judge = 0;
		for (int index0 = 0; index0 < (int) (190); index0++) {
			for (int index1 = 0; index1 < (int) (16); index1++) {
				for (int index2 = 0; index2 < (int) (16); index2++) {
					if (BlockTags.getCollection().getTagByID(new ResourceLocation("minecraft:logs"))
							.contains((world.getBlockState(new BlockPos((int) fx, (int) fy, (int) fz))).getBlock())
							|| BlockTags.getCollection().getTagByID(new ResourceLocation("minecraft:leaves"))
									.contains((world.getBlockState(new BlockPos((int) fx, (int) fy, (int) fz))).getBlock())) {
						if (world instanceof World) {
							Block.spawnDrops(world.getBlockState(new BlockPos((int) fx, (int) fy, (int) fz)), (World) world,
									new BlockPos((int) fx, (int) fy, (int) fz));
							world.destroyBlock(new BlockPos((int) fx, (int) fy, (int) fz), false);
						}
					} else {
						judge = (judge + 1);
					}
					fx = (fx + 1);
				}
				fx = nx;
				fz = (fz + 1);
			}
			if (fy >= y && judge == 256) {
				break;
			}
			fz = nz;
			fy = (fy + 1);
			judge = 0;
		}
	}
}
